﻿/*
 * RegExpress
 * 
 * Copyright (c) 2010, Daniel McGaughran
 * 
 * Licensed under the Apache Licence, Version 2.0 (the "Licence");
 * you may not use this file except in compliance with the Licence.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the Licence is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and
 * limitations under the Licence.
 * 
 */

using System;
using System.Xml;
using RegExpressModel.Utility;


namespace RegExpressModel
{
	public class SlideSettings : ISettingsSerialiser
	{

		internal SlideSettings()
		{
			CurrentSlideName = "";
		}



		public string CurrentSlideName
		{ get; set; }



		public void SaveToXml(XmlDocument targetDocument, XmlElement targetElement)
		{
			XmlElement windowSettingsNode = targetElement.AppendElement(targetDocument, Constants.SlideSettingsNodeName);
			windowSettingsNode.AppendElement(targetDocument, Constants.CurrentSlideNameNodeName, CurrentSlideName);
		}



		public bool ExtractFromXml(XmlElement parentElement)
		{
			string currentValue;
			bool allSettingsLoaded = true;

			currentValue = parentElement.GetTextValue(Constants.CurrentSlideNameXPath);
			if (!String.IsNullOrEmpty(currentValue))
				CurrentSlideName = currentValue;
			else allSettingsLoaded = false;

			return allSettingsLoaded;
		}


	}
}
